import type { ExpressData, MedicalOrderDetail, OrderPre } from "@/types/order"
import { request } from "@/utils/http"

/**
 * 药品预付订单
 */
export const preOrderApi = (prescriptionId: string) => {
  return request.get<null, OrderPre>("/patient/medicine/order/pre", {
    params: { prescriptionId },
  })
}
/**
 * 药品待支付订单
 */
export const createUnpaidOrderApi = (id: string, addressId: string) => {
  return request.post<null, { id: string }>("/patient/medicine/order", {
    id,
    addressId,
  })
}

/**
 * 获取药品订单详情
 * @param id 订单id
 * @returns
 */
export const getMedicalOrderDetail = (id: string) => {
  return request.get<null, MedicalOrderDetail>(
    `/patient/medicine/order/detail/${id}`
  )
}
/**
 * 药品订单列表
 * @param status 订单状态
 * @param current 当前页面
 * @param pageSize 页容量
 * @returns
 */
export const orderListApi = (status = 10, current = 1, pageSize = 10) => {
  return request.get<null, any>("/patient/medicine/order/mylist", {
    params: { status, current, pageSize },
  })
}

/** 获取药品订单物流信息 */
export const getMedicalOrderLogistics = (id: string) => {
  return request.get<null, ExpressData>(`/patient/order/${id}/logistics`)
}
